package cn.xing.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.Date;

@Aspect
@Component
public class LogAspect {
	private static final Logger logger = LoggerFactory.getLogger(LogAspect.class);

	// cn.xing.controller.HomeController
	@Before("execution(* cn.xing.controller.*Controller.*(..))")
	public void beforeMethod(JoinPoint joinPoint) {
		StringBuilder sb = new StringBuilder();
		for (Object arg : joinPoint.getArgs()) {
			sb.append("arg:" + arg.toString() + "|");
		}
		logger.info("Controller执行前：: " + sb.toString());
	}

	@After("execution(* cn.xing.controller.*Controller.*(..))")
	public void afterMethod(JoinPoint joinPoint) {
		logger.info("Controller执行后：: ");
	}
}
